package com.uenpay.oem.ui.auth;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.FrameLayout;

import com.uenpay.oem.R;
import com.uenpay.oem.data.bean.UserIdCardInfo;
import com.uenpay.util.app.base.BaseActivity;

import butterknife.BindView;

/**
 * Author: liulou
 * Date: 2017/6/16.
 * desc: 实名认证界面
 */

public class AuthActivity extends BaseActivity implements AuthFragmentChangeCallback {

    @BindView(R.id.fl_content)
    FrameLayout flContent;

    private Fragment mFragment;

    @Override
    public View bindView() {
        return null;
    }

    @Override
    public int bindLayout() {
        return R.layout.activity_auth;
    }

    @Override
    public void initView(View view) {
        setTitle("实名认证");
        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction ft = manager.beginTransaction();
        mFragment = UploadIdCardFragment.newInstance(this);
//        AuthConfirmFragment fragment = new AuthConfirmFragment();
//        AuthSuccessFragment fragment = new AuthSuccessFragment();
        ft.replace(R.id.fl_content, mFragment);
        ft.addToBackStack("UploadIdCardFragment");
        ft.commit();
    }

    @Override
    public void authSuccess() {
        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction ft = manager.beginTransaction();
        mFragment = AuthSuccessFragment.newInstance(this);
        ft.replace(R.id.fl_content, mFragment);
        ft.commit();
    }

    @Override
    public void uploadIdCardSuccess(UserIdCardInfo info) {
        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction ft = manager.beginTransaction();
        mFragment = AuthConfirmFragment.newInstance(this);
        Bundle bundle = new Bundle();
        bundle.putParcelable("info", info);
        mFragment.setArguments(bundle);
        ft.replace(R.id.fl_content, mFragment);
        ft.addToBackStack(TAG);
        ft.commit();
    }
}
